<?php

// phpMyRealty 3
//
// File Name: searchFormMain.php
// File Location : ./templates/default/
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

?>
<!-- Simple search form Horizontal : start -->

<div class="advanced-search">
	<div class="t">
		<div class="holder">
			<form action="<?php echo URL ?>/search.php" method="POST">
				<fieldset>
					<div class="title">
						<h3>FIND A PROPERTY</h3>
						<a href="<?php echo URL ?>/advsearchform.php">Advanced Search</a>
					</div>
					<div class="form">
						<div class="col1">
							<h4><?php echo $lang['WHAT']; ?>:</h4>
							<?php 
							 	 if (strcasecmp($conf['show_mls'], 'OFF') != 0) {
							 	      echo $lang['Listing_MLS'] . '<br />
								 <input type="text" name="mls" size="20" />
								 <br /><br />';
							 	  }
							?>
							
							 	 <?php echo $lang['Module_Listing_Type'] . '<br />'; ?>
							         <select name="type2">
								  <option value="ANY" class="price_range_any"><?php echo $lang['Search_Any'] . ' ' . $lang['Module_Listing_Type'];?></option>
								  <?php echo generate_options_list ( TYPES2_TABLE, '', 'price_range_' )?>
							         </select>
							
								<br /><br />
							
							 	 <?php echo $lang['Listing_Property_Type'] . '<br />'; ?>
							 	 <div id="typesdiv" name="typesdiv">
							         <select name="type">
								  <option value="ANY"><?php echo $lang['Search_Any'] . ' ' . $lang['Listing_Property_Type'];?></option>
								  <?php echo generate_options_list ( TYPES_TABLE )?>
							         </select>
							     </div>
						</div>
						<div class="col2">
							<h4><?php echo $lang['WHERE']; ?>:</h4>
							<?php echo $lang['Location'] ?> <br />
						
						          <select name="location1" class="span3" id="location1" onchange="xajax_fetchLocations2(this.value);">
						
						<?php
						
						    $r_location1 = $db->query('SELECT selector, category FROM ' . LOCATION1_TABLE . ' ORDER BY category ASC');
						
						    $newContentMain = '<option value="ANY">' . $lang['Select'] . '</option>' . "\n";
						   
						    while ($f_location1 = $db->fetcharray($r_location1)) {
						     $newContentMain.= '<option value="' . $f_location1['selector'] . '">' . $f_location1['category'] . '</option>' . "/n";
						    }
						
						    echo $newContentMain;
						
						?>
						          </select>
						          <div style="display: inline" id="location2div" name="location2div"></div>
						          <div style="display: inline" id="location3div" name="location3div"></div>
						
						 	 <br /><br />
						
						<?php 
						  if (strcasecmp(@$conf['show_postal_code'], 'OFF') != 0) {
							 echo $lang['Zip_Code'] . '<br />
							 <input type="text" name="zip" size="20" />
							 <br /><br />';
						  }
						?>
						
							 <input type="checkbox" name="image_uploaded" value="1">
							 <?php echo $lang['Search_Images_Only']; ?>
						</div>
						<div class="col3">
							<h4><?php echo $lang['OPTIONS']; ?>:</h4>
		
		    <div id="search_price">
		
		        <?php echo $lang['Search_Price_Range']; ?><br />
		        <?php
		         $price_ranges = array();
		         $price_ranges['monthly'] = array();
		         for ($i = $conf['price_monthly_range_min']; $i <= $conf['price_monthly_range_max']; $i = $i + $conf['price_monthly_range_step']) {
		             $price_ranges['monthly'][] = $i;
		         }
		         $price_ranges['sale'] = array();
		         for ($i = $conf['price_range_min']; $i <= $conf['price_range_max']; $i = $i + $conf['price_range_step']) {
		             $price_ranges['sale'][] = $i;
		         }
		         $price_ranges['any'] = array_unique(array_merge($price_ranges['monthly'], $price_ranges['sale']));
		         sort($price_ranges['any']);
		         
		         foreach ($price_ranges as $_range => $_prices) {
		             switch ($_range) {
		             case 'any':
		                 $_style = '';
		                 break;
		             default:
		                 $_style = ' style="display: none;" ';
		                 break;
		             }
		?>
		        <table id="price_range_<?php echo $_range; ?>" <?php echo $_style; ?>class="price_range" cellpadding="0" cellspacing="0" border="0">
					<tr>
					<td>
					         <select name="price_min_<?php echo $_range; ?>">
					      <option value="ANY"><?php echo $lang['Search_Any'];?></option>
					<?php
					             $price_range = '';
					             foreach ($_prices as $i) {
					                $selected = ($i == $search['price_min']) ? ' selected="selected"' : '';
					                $price_range.= '<option value="' . $i . '"'.$selected.'>' . $conf['currency'] . ' ' . number_format($i) . '</option>' . "\n";
					             }
					        
					             echo $price_range;
					?>
					         </select><br />
						 <?php echo $lang['Search_To']; ?><br />
					         <select name="price_max_<?php echo $_range; ?>">
					      <option value="ANY"><?php echo $lang['Search_Any'];?></option>
					<?php
					             $price_range = '';
					             foreach ($_prices as $i) {
					                 $selected = ($i == $search['price_max']) ? ' selected="selected"' : '';
					                 $price_range.= '<option value="' . $i . '"'.$selected.'>' . $conf['currency'] . ' ' . number_format($i) . '</option>' . "\n";
					             }
					             echo $price_range; 
					?>
			         </select>
			         </td></tr>
			    </table>
			 
		<?php 
		         }
		
		?>
		
			    <div class="rows">
					<input class="submit" type="submit" value="Search" />
				</div>
		
		<script type="text/javascript">
		(function($){
		    $(document).ready(function() {
		        $(":select[name=type2]").change(function() {
		            var c = $(":select[name=type2] option:selected").attr("class");
		            $(".price_range").hide();
		            $("#" + c).show();
		        });
		        $(":select[name=type2]").change();
		    });
		})(jQuery);
		</script>
		
		   </div>
				</fieldset>
			</form>
		</div>
	</div>
</div>

<!-- Simple search form Horizontal : stop -->